<?php
namespace Home\Controller;
use Common\Controller\CommonController;
class FwController extends CommonController {
	
	function index(){
		
		
		$type=I('type');
		if($type!=""){
		$where['type']=$type;			
		$count=M('fw')->where($where)->count();
		$page=new \Think\Page($count,20);
		$show=$page->show();	
		$re=M('fw')->limit($page->firstRow.','.$page->listRows)->where($where)->select();
		
		}else{
			
		$count=M('fw')->count();
		$page=new \Think\Page($count,20);
		$show=$page->show();	
		$re=M('fw')->limit($page->firstRow.','.$page->listRows)->select();
		
	
		}
		$this->assign('page',$show);
		$this->assign('list',$re);
		$this->display('index');
	}
	
	function addfw(){
		
		$name=I('name');
		$type=I('type');
		if($name){
		$data=array(
			'name'=>$name,
			'type'=>$type,
		);
		$re=M('fw')->add($data);	
		if($re){
		$this->redirect('Fw/index');	
		}
		
		}else{
		$this->display('add');	
		}
	}

	function delfw(){
		$where['id']=I('id');
		$re=M('fw')->where($where)->delete();
		if($re){
		$this->redirect('Fw/index');	
		}
	}
	
	
	
}